#include "Vector2D.h"
#include "Entity.h"
/*
 *Consumer.
 *Mostly animals.
*/
#ifndef DS_ECOSYSTEM_COMSUMER
#define DS_ECOSYSTEM_COMSUMER

class Consumer : public Entity
{
public:
    virtual bool is_producer() const;
    virtual bool is_consumer() const;

    double    get_speed() const;
    void    set_speed(double speed);
    double    get_init_speed() const;
    void    set_init_speed(double init_speed);
    
    //reactions
    virtual void on_eaten();

    //behaviors
    virtual bool prey(double speed);
    virtual bool brownian_motion(double speed);
    virtual bool random_motion(double speed);
    virtual bool avoid_predator(double speed);
    virtual bool is_near_edge() const;
    virtual void set_life_span(int);
    virtual int get_life_span() const;
    virtual double get_speed_limit()const;
    virtual int get_hp_limit()const;
    virtual void natural_growth();
    virtual void multiply();
    virtual double get_environment_factor();
    
    virtual double hungry();
protected:
    Consumer(EcoSystem *eco_system);

    //A structure used in avoid predator behavior
    struct avoid_predator_structure
    {
        int t;
        Vector2D v;
        bool b;
        avoid_predator_structure() : t(0x3f3f3f3f) {}
    }aps;
private:
    double speed, init_speed;
    int life_span;
};

#endif // DS_ECOSYSTEM_COMSUMER
